// pages/mine/bangding/bangding.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    msg: '',//新密码
    msg1: '', //确认新密码
    userUsername: '',
    userInfo: '',
    userPassword: ''
  },
  xiugai(e) {
    console.log(e.detail.value);
    this.setData({
      msg: e.detail.value
    })
  },
  xiugai1(e) {
    console.log(e.detail.value);
    this.setData({
      msg1: e.detail.value
    })
  },
  queding() {
    console.log(this.data.msg);
    var that = this;
    if (this.data.msg === this.data.msg1) {
      wx.request({
        url: 'http://localhost:8081/my/updatePassword',
        method: 'POST',
        data: {
          userPassword: that.data.msg,
          userUsername: that.data.userUsername
        },
        success(res) {
          that.setData({
            msg: res.data.data
          });
        }
      })
    }else{
      wx.showToast({
        title: '两次密码不一致',
      })
    }


  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let app = getApp();
    var that = this;
    that.data.userInfo = app.globalData.userInfo;
    console.log(that.data.userInfo);
    that.data.userUsername = that.data.userInfo.data[2].userUsername;
    console.log(that.data.userUsername);

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})